{template('header.html')}

<script type="text/javascript">
<!--
function IsValidName(s) {
	var pattern=/^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){3,19}$/;
	if (!pattern.exec(s)) { //exec方法
		return false;
	}
	/*
	if (!pattern.test(s)) { //test方法
		return false;
	}
	*/
	else {
		return true;
	}
}

function CheckForm(){
        if (document.editform.name.value==""){
            alert("标签名称不能为空！");
            document.editform.name.focus();
            return false;
        }

        if (!IsValidName(document.editform.name.value)){
            alert("标签名只能由4-20位的英文字母(包括大小写)开头及_字符和数字构成。");
            document.editform.name.focus();
            return false;
        }


        if (document.editform.sortname.value==""){
            alert("标签分类不能为空！");
            document.editform.sortname.focus();
            return false;
        }

        if (document.editform.level.value==""){
            alert("优先指数不能为空！");
            document.editform.level.focus();
            return false;
        }

        if (document.editform.content.value==""){
            alert("标签内容不能为空！");
            document.editform.content.focus();
            return false;
        }
}

function HideError() {
		return true;
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tb_style">
	<form action="{:U(MODULE_NAME &'/'& ACTION_NAME)}" method="post" name="editform" >
		<tr>
			<td colspan="3" class="td_title">&nbsp;添加自定义标签</td>
		</tr>
		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;自定义标签名称：&nbsp;</td>
			<td width="87%" class="td_border">
			{cmsself:<input type="text" name="name" id="name" value="{$rs('name')}" size="35" onfocus="this.style.borderColor='#F93'" onblur="this.style.borderColor='#CCC'" />}
			<font color="#FF0000">*&nbsp;输入名称即可（英文要注意大小写），不用输入定界符，且不可重复。</font></td>
		</tr>
		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;自定义标签分类：&nbsp;</td>
			<td width="87%" class="td_border">
			<input type="text" name="sortname" id="sortname" value="{:M('custom_labelsort')().Find(rs('sortid')).getField('name')}" size="30" onfocus="this.style.borderColor='#F93'" onblur="this.style.borderColor='#CCC'" />
			<select onChange='sortname.value=this.value;'>
			<option value=''>新增分类</option>
			{$rssort type='rs'}
			<option  value='{$rssort('name')}'>{$rssort('name')}</option>
			{/$rssort}

			</select>
			<font color="#FF0000">*</font></td>
		</tr>
		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;标签开启状态：&nbsp;</td>
			<td width="87%" class="td_border">
			<select name="status" id="status" style="width:60px;">
			<option value='1'{if rs('status')=1} selected='selected'{/if}>启用</option>
			<option value='0'{if rs('status')=0} selected='selected'{/if}>禁用</option>
			</select>
			<font color="#008000">*&nbsp;“禁用状态”则表示屏蔽标签内容解析</font></td>
		</tr>
		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;自定义标签描述：&nbsp;</td>
			<td width="87%" class="td_border">
			<input type="text" name="intro" id="intro" value="{$rs('intro')}" size="80" onfocus="this.style.borderColor='#F93'" onblur="this.style.borderColor='#CCC'" />
			<font color="#FF0000"></font></td>
		</tr>

		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;标签优先指数：&nbsp;</td>
			<td width="87%" class="td_border">
			<input type="text" name="level" id="level" value="{$rs('level')}" size="10" maxlength="9"
			onfocus="this.style.borderColor='#F93'" onblur="this.style.borderColor='#CCC'"
			onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
			<font color="#FF0000">*&nbsp;优先指数越高,优先级越高。新增的标签优先级比旧标签高。当标签中再嵌套调用其他标签时,就需要决定标签的优先级。</font></td>
		</tr>

		<tr>
			<td width="13%" height="30" class="td_border" align="right">&nbsp;自定义标签内容：&nbsp;</td>
			<td width="87%" class="td_border">
			<textarea name="content" id="content" rows="20" cols="100" 
			onfocus="this.style.borderColor='#F93'" onblur="this.style.borderColor='#CCC'">{$rs('content')}</textarea>
			<br>&nbsp;<font style="color:#FF0000">*&nbsp;支持调用<a href="###" style="color:#00BBFF;text-decoration: underline;">系统标签</a>。</font></td>
		</tr>
		<tr>
			<td width="100%" height="40" colspan="2" align="center" class="td_border"> &nbsp;
			<input type="hidden" name="id" id="id" value="{$rs('id')}" />
			<input type="submit" name="Submit" value="确认保存" class="rb1" onClick="return CheckForm();"/>
			&nbsp;&nbsp;<input type="reset" name="reset" value="重置数据" class="rb1" />
			&nbsp;&nbsp;<input type="button" name="button" value="字符互转" class="rb1" onclick="ConvertChar('content');" />
			</td>
		</tr>
	</form>
</table>

{template('footer.html')}